<template>
  <a-card :bordered="false">
    <a-row type="flex" align="top" style="margin-bottom: 20px;">
      <a-col :span="4">
        <j-image-upload text="上传人像图" bizPath="scott/specialPerson" @change="changeImage" v-model="headPortrait" />
      </a-col>
      <a-col :span="6">
        <h2>
          {{ basicInfoResult.name }}
          <a-tag color="red" style="margin-left: 8px;" v-if="basicInfoResult.typeOfHazardAssessment&&basicInfoResult.typeOfHazardAssessment=='01'">
            {{ this.$filterDictTextByCache('dangerous', basicInfoResult.typeOfHazardAssessment) }}
          </a-tag>
        </h2>
        <p>公民身份号码：{{ basicInfoResult.identityCard }}</p>
        <p>出生日期：{{ basicInfoResult.birthday }}</p>
        <p>户籍地：{{ basicInfoResult.registeredResidence }}</p>
      </a-col>
      <a-col :span="6" style="margin-top:42px;">
        <p>联系方式：{{ basicInfoResult.number }}</p>
        <p>性别：{{ this.$filterDictTextByCache('sex', basicInfoResult.sex) }}</p>
        <p>户籍门(楼)详址：{{ basicInfoResult.registeredDetailedAddress }}</p>
      </a-col>
      <a-col :span="8" style="text-align: right;">
        <a-button @click="handleAlarm()">一键报警</a-button>
      </a-col>
    </a-row>
    <a-tabs v-model="tabValue">
      <template v-for="item in tabDatas">
        <a-tab-pane :key="item.key" :tab="item.tab" v-if="!item.hidden">
          <!--//基本信息-->
          <template v-if="tabValue == 1">
            <a-descriptions :column="1">
              <a-descriptions-item :label="obj.label" v-for="(obj, i) in basicInfo" :key="i">
                {{ basicInfoResult[obj.field]?basicInfoResult[obj.field]: '-' }}
              </a-descriptions-item>
            </a-descriptions>
          </template>
          <!--//告警信息-->
          <template v-if="tabValue == 2">
            <z-table
              ref="table"
              rowKey="alarmInfoId"
              :showAlert="false"
              :showSelection="false"
              :columns="alarmInfoColumns"
              :dataSource="alarmInfoResult"
              @change="onTableChange1"
            />
          </template>
          <!--//处置信息-->
          <template v-if="tabValue == 3">
            <div style="text-align: right;margin-bottom: 10px;">
              <a-button @click="handleDispose('addDispose',basicInfoResult)">新增处置信息</a-button>
            </div>
            <z-table
              ref="table"
              rowKey="disposeId"
              :showAlert="false"
              :showSelection="false"
              :columns="disposalInfoColumns"
              :dataSource="disposalInfoResult"
              @change="onTableChange2"
            />
          </template>
          <!--//刑满释放人员-帮教信息-->
          <template v-if="tabValue == 4">
            <info-table :data="helpTeachInfo1" :infoData="infoData.info1" />
          </template>
          <!--//社区矫正人员-社区矫正人员信息-->
          <template v-if="tabValue == 5">
            <info-table :data="correctionInfo" :infoData="infoData.info1" />
          </template>
          <!--//吸毒人员-专项信息-->
          <template v-if="tabValue == 6">
            <info-table :data="specialInfo1" :infoData="infoData.info1" />
          </template>
          <!--//吸毒人员-帮教记录-->
          <template v-if="tabValue == 7">
            <info-table :data="helpTeachInfo2" :infoData="infoData.info2" />
          </template>
          <!--//艾滋病危险人员-帮扶信息-->
          <template v-if="tabValue == 8">
            <info-table :data="helpInfo" :infoData="infoData.info1" />
          </template>
          <!--//肇事肇祸等严重精神障碍患者-专项信息-->
          <template v-if="tabValue == 9">
            <info-table :data="specialInfo2" :infoData="infoData.info1" />
          </template>
          <!--//肇事肇祸等严重精神障碍患者-管控信息-->
          <template v-if="tabValue == 10">
            <info-table :data="controlInfo" :infoData="infoData.info2" />
          </template>
          <!--//重点青少年-人员分类及成因-->
          <template v-if="tabValue == 11">
            <info-table :data="personnelClassificationInfo" :infoData="infoData.info1" />
          </template>
          <!--//重点青少年-帮教信息-->
          <template v-if="tabValue == 12">
            <info-table :data="helpTeachInfo3" :infoData="infoData.info2" />
          </template>
        </a-tab-pane>
      </template>
    </a-tabs>
    <dispose-modal ref="disposeModal" @ok="getOk" />
    <alarm-modal ref="alarmModal" />
    <a-modal v-model="visible" title="处置信息" @ok="hideModal">
      <p>{{ alarmInfo.disposalContents }}</p>
      <template slot="footer">
        <a-button key="back" @click="showDispose"> 编辑 </a-button>
        <a-button key="submit" type="primary" @click="hideModal"> 确定 </a-button>
      </template>
    </a-modal>
  </a-card>
</template>
<script>
import * as specialApi from '@/api/xlgc/special.js'
import InfoTable from './modules/table'
import disposeModal from './modules/disposeModal'
import alarmModal from './modules/alarmModal'
export default {
  components: {
    InfoTable,
    disposeModal,
    alarmModal
  },
  data() {
    return {
      type: null,
      id: null,
      tabValue: 1,
      visible: false,
      alarmInfo: {},
      headPortrait: null,
      pageFilter1: { pageNo: 1, pageSize: 10 },
      pageFilter2: { pageNo: 1, pageSize: 10 },
      // 基本信息-字段
      basicInfo: [
        { field: 'beforeName', label: '曾用名' },
        { field: 'nation_txt', label: '民族' },
        { field: 'nativePlace', label: '籍贯' },
        { field: 'servicePremises', label: '服务处所' },
        { field: 'maritalStatus_txt', label: '婚姻状况' },
        { field: 'politicalOutlook_txt', label: '政治面貌' },
        { field: 'education_txt', label: '学历' },
        { field: 'religiousBelief_txt', label: '宗教信仰' },
        { field: 'occupationalCategory_txt', label: '职业类别' },
        { field: 'occupation', label: '职业' },
        { field: 'currentResidence', label: '现住地' },
        { field: 'currentDetailedAddress', label: '现住门(楼)详址' }
      ],
      // 告警信息-字段
      alarmInfoColumns: [
        {
          title: '序号',
          dataIndex: 'order',
          align: 'center',
          customRender: (text, record, index) =>
            `${(this.pageFilter1.pageNo - 1) * this.pageFilter1.pageSize + (index + 1)}` // 序号分页后连续
        },
        {
          title: '告警时间',
          dataIndex: 'alarmDate'
        },
        {
          title: '告警类型',
          dataIndex: 'alarmType',
          customRender: (text, record, index) => {
            return <span style={'color: ' + (text == '漫入' ? 'red;' : '#FF8004;')}>{text}</span>
          }
        },
        {
          title: '告警位置',
          dataIndex: 'alarmRegion'
        },
        {
          title: '操作',
          dataIndex: 'action',
          align: 'center',
          customRender: (text, record, index) => {
            if (record && record.ynDisposal == 1) {
              return (
                <a-space class="action-button">
                  <a-button type="link" style="padding: 0;" onClick={(event) => this.showModal(record)}>已处置</a-button>
                  <a-button type="link" style="padding: 0;" onClick={(event) => this.handleDispose('alarmDispose', record)}>编辑</a-button>
                </a-space>
              )
            } else if (record && record.ynDisposal == 0) {
              return (
                <a-button type="link" style="padding: 0;" onClick={(event) => this.handleDispose('alarmDispose', record)}>待处置</a-button>
              )
            }
          }
        }
      ],
      // 处置信息-字段
      disposalInfoColumns: [
        {
          title: '序号',
          dataIndex: 'order',
          align: 'center',
          width: 60,
          customRender: (text, record, index) =>
            `${(this.pageFilter2.pageNo - 1) * this.pageFilter2.pageSize + (index + 1)}` // 序号分页后连续
        },
        {
          title: '处置内容',
          dataIndex: 'disposalContents',
          width: 400,
          align: 'center',
          customRender: text => {
            return <j-ellipsis value={text} length={80} />
          }
        },
        {
          title: '处置时间',
          dataIndex: 'createTime',
          width: 220
        },
        {
          title: '录入员',
          dataIndex: 'createBy',
          width: 120
        },
        {
          title: '操作',
          dataIndex: 'action',
          align: 'center',
          width: 120,
          customRender: (text, record, index) => {
            return (
              <a-space class="action-button">
                <a-button type="link" style="padding: 0;" onClick={(event) => this.handleDeleteDispose(record)}>删除</a-button>
                <a-button type="link" style="padding: 0;" onClick={(event) => this.handleDispose('editDispose', record)}>编辑</a-button>
              </a-space>
            )
          }
        }
      ],
      // 基本信息-值
      basicInfoResult: {},
      // 告警信息-值
      alarmInfoResult: {},
      // 处置信息-值
      disposalInfoResult: {},
      // 刑满释放人员-帮教信息
      helpTeachInfo1: [
        {
          fieldParameter: [
            { field: 'ynRecidivism_txt', label: '是否累犯' },
            { field: 'originalSinName_txt', label: '原罪名' },
            { field: 'originalSentence', label: '原判刑期' },
            { field: 'placeOfImprisonment', label: '服刑场所' }
          ]
        },
        {
          fieldParameter: [
            { field: 'releaseDate', label: '释放日期' },
            { field: 'typeOfHazardAssessment_txt', label: '危险性评估类型' },
            { field: 'connectionDate', label: '衔接日期' },
            { field: 'connection_txt', label: '衔接情况' }
          ]
        },
        {
          fieldParameter: [
            { field: 'placement_txt', label: '安置情况', colspan: 3 },
            { field: 'placementDate', label: '安置日期', colspan: 3 }
          ]
        },
        {
          fieldParameter: [
            { field: 'notSettledInfo', label: '未安置原因', colspan: 2 },
            { field: 'recidivism_txt', label: '是否重新犯罪', colspan: 2 },
            { field: 'recidivismName', label: '重新犯罪罪名' }
          ]
        },
        {
          rowspan: 9,
          rowlabel: '帮教情况',
          labelHeader: false,
          fieldParameter: [
            { field: 'helpTeachYear', label: '年度', colspan: 3 },
            { field: 'helpTeachName', label: '帮教人姓名', colspan: 2 }
          ]
        },
        {
          rowspan: 2,
          rowlabel: '一季度',
          labelHeader: true,
          fieldParameter: [
            { field: 'firstQuarterHelpTeachInfo', label: '帮教情况', colspan: 3 },
            { field: 'firstQuarterThoughtInfo', label: '刑释人员思想情况', colspan: 3 }
          ]
        },
        {
          rowspan: 2,
          rowlabel: '二季度',
          labelHeader: true,
          fieldParameter: [
            { field: 'secondQuarterHelpTeachInfo', label: '帮教情况', colspan: 3 },
            { field: 'secondQuarterThoughtInfo', label: '刑释人员思想情况', colspan: 3 }
          ]
        },
        {
          rowspan: 2,
          rowlabel: '三季度',
          labelHeader: true,
          fieldParameter: [
            { field: 'thirdQuarterHelpTeachInfo', label: '帮教情况', colspan: 3 },
            { field: 'thirdQuarterThoughtInfo', label: '刑释人员思想情况', colspan: 3 }
          ]
        },
        {
          rowspan: 2,
          rowlabel: '四季度',
          labelHeader: true,
          fieldParameter: [
            { field: 'fourthQuarterHelpTeachInfo', label: '帮教情况', colspan: 3 },
            { field: 'fourthQuarterThoughtInfo', label: '刑释人员思想情况', colspan: 3 }
          ]
        },
        {
          rowspan: 2,
          rowlabel: '帮教责任人',
          labelHeader: true,
          fieldParameter: [
            { field: 'cadreJudicialOffice', label: '司法所干部', colspan: 2 },
            { field: 'townStreetCadres', label: '镇街干部' },
            { field: 'communityPolice', label: '社区民警' },
            { field: 'villageCadres', label: '村居干部' },
            { field: 'districtVolunteers', label: '辖区志愿者' },
            { field: 'familyMembersRelatives', label: '家属或亲属' }
          ]
        },
        {
          fieldParameter: [
            { field: 'implementationTimePolicies', label: '落实政策情况时间', colspan: 2 },
            { field: 'employment', label: '从业情况', colspan: 2 },
            { field: 'prisonsSkillTraining', label: '在监所受何种技能培训' }
          ]
        },
        {
          fieldParameter: [
            { field: 'regressionSkillTraining', label: '回归后受何种技能培训', colspan: 2 },
            { field: 'nowWhatSkills', label: '现掌握何种技能', colspan: 2 },
            { field: 'resettlement', label: '安置情况' }
          ]
        },
        {
          fieldParameter: [
            { field: 'resettlementMode', label: '安置方式', colspan: 3 },
            { field: 'other', label: '其它', colspan: 3 }
          ]
        }
      ],
      // 社区矫正人员-社区矫正人员信息
      correctionInfo: [
        {
          fieldParameter: [
            { field: 'serialNumber', label: '社区矫正人员编号', colspan: 2 },
            { field: 'tiredRecidivist_txt', label: '是否累惯犯' },
            { field: 'specificCharges', label: '具体罪名' }
          ]
        },
        {
          fieldParameter: [
            { field: 'judgmentCode', label: '判决书号', colspan: 2 },
            { field: 'courtLevel', label: ' 法院级别' },
            { field: 'punishmentTypes', label: '刑种' }
          ]
        },
        {
          fieldParameter: [
            { field: 'adjudicationAuthority', label: '判决机关', colspan: 2 },
            { field: 'accessNumber', label: ' 判决日期' },
            { field: 'responseCode', label: '原判刑期' }
          ]
        },
        {
          fieldParameter: [
            { field: 'case_category', label: '案件类别', colspan: 2 },
            { field: 'originalSentenceStartDate', label: '原判刑开始日期' },
            { field: 'originalSentenceEndDate', label: '原判刑结束日期' }
          ]
        },
        {
          fieldParameter: [
            { field: 'supplementaryPunishment', label: '附加刑', colspan: 2 },
            { field: 'accessNumber', label: '原羁押场所' },
            { field: 'responseCode', label: '监管级别' }
          ]
        },
        {
          fieldParameter: [
            { field: 'receivingMethod', label: '接收方式', colspan: 2 },
            { field: 'receivingDate', label: '接收时间' },
            { field: 'fourHistories_txt', label: '"四史"情况' }
          ]
        },
        {
          fieldParameter: [
            { field: 'threeInvolved_txt', label: '"三涉"情况', colspan: 2 },
            { field: 'correctionCategory_txt', label: '矫正类别' },
            { field: 'correctionStartDate', label: '矫正开始日期' }
          ]
        },
        {
          fieldParameter: [
            { field: 'correctionEndDate', label: '矫正结束日期', colspan: 2 },
            { field: 'ynCorrectionTeam_txt', label: '是否建立矫正小组' },
            { field: 'correctionTeamPersonnel_txt', label: '矫正小组人员' }
          ]
        },
        {
          fieldParameter: [
            { field: 'correctionReleaseType_txt', label: '矫正解除(终止)类型', colspan: 2 },
            { field: 'releaseCorrectionDate', label: '解矫日期' },
            { field: 'ynGetRidControl_txt', label: '是否有脱管' }
          ]
        },
        {
          fieldParameter: [
            { field: 'reasonsPipeDisconnection', label: '脱管原因', colspan: 2 },
            { field: 'omissionSupervisionInspection', label: '检察监督脱管情况' },
            { field: 'correctionPipeDisconnection', label: '脱管纠正情况' }
          ]
        },
        {
          fieldParameter: [
            { field: 'ynLeakAdminister_txt', label: '是否有漏管', colspan: 2 },
            { field: 'leakAdministerReason', label: '漏管原因' },
            { field: 'omissionSupervisionInspection', label: '检察监督漏管情况' }
          ]
        },
        {
          fieldParameter: [
            { field: 'leakageCorrection', label: '漏管纠正情况', colspan: 2 },
            { field: 'recidivism_txt', label: '是否重新犯罪' },
            { field: 'recidivismName', label: '重新犯罪名称' }
          ]
        },
        {
          fieldParameter: [{ field: 'executionPenaltyChange', label: '刑罚变更执行情况', colspan: 6 }]
        },
        {
          rowspan: 2,
          rowlabel: '刑期变动',
          labelHeader: true,
          fieldParameter: [
            { field: 'changeSentenceType', label: '类型' },
            { field: 'changeSentenceRevisionDate', label: '改判时间' },
            { field: 'changeSentenceExecutionStartDate', label: '执行开始时间', colspan: 2 },
            { field: 'changeSentenceExecutionEndDate', label: '执行结束时间', colspan: 2 }
          ]
        },
        {
          rowspan: 2,
          rowlabel: '同案犯',
          labelHeader: true,
          fieldParameter: [
            { field: 'accompliceName', label: '姓名' },
            { field: 'accompliceSex_txt', label: '性别' },
            { field: 'accompliceBirthDate', label: '出生日期' },
            { field: 'accompliceTermImprisonment', label: '刑期' },
            { field: 'accompliceAccusation', label: '罪名' },
            { field: 'accompliceHomeAddress', label: '家庭地址' }
          ]
        },
        {
          fieldParameter: [{ field: 'mainCriminalFacts', label: '主要犯罪事实', colspan: 6 }]
        },
        {
          fieldParameter: [
            { field: 'correctionIdeas', label: '矫正工作思路', colspan: 2 },
            { field: 'correctiveMeasures', label: '矫正措施' },
            { field: 'rewardsPunishments', label: '奖惩情况' }
          ]
        }
      ],
      // 吸毒人员-专项信息
      specialInfo1: [
        {
          fieldParameter: [
            { field: 'initialDiscoveryDate', label: '初次发现日期' },
            { field: 'control_txt', label: '管控情况' },
            { field: 'controllerName', label: '管控人姓名' }
          ]
        },
        {
          fieldParameter: [
            { field: 'controllerContactInformation', label: '管控人联系方式', colspan: 2 },
            { field: 'criminalHistory', label: '有无犯罪史', colspan: 2 }
          ]
        },
        {
          fieldParameter: [{ field: 'crimeSituation', label: '犯罪情况', colspan: 5 }]
        },
        {
          fieldParameter: [
            { field: 'drugAbuseReasons', label: '吸毒原因', colspan: 2 },
            { field: 'drugAbuseConsequences', label: '吸毒后果', colspan: 2 }
          ]
        }
      ],
      // 吸毒人员-帮教记录
      helpTeachInfo2: [
        {
          fieldParameter: [
            { field: 'helpEducationgroupName', label: '帮教小组名称' },
            { field: 'groupLeader', label: '帮教小组组长' },
            { field: 'groupLeaderTelephone', label: '帮教小组组长电话' }
          ]
        },
        {
          fieldParameter: [
            { field: 'teachingTime', label: '帮教时间' },
            { field: 'helperName', label: '帮扶人姓名' },
            { field: 'helperTelephone', label: '帮扶人联系方式' }
          ]
        },
        {
          rowspan: 2,
          rowlabel: '帮教对象',
          labelHeader: true,
          fieldParameter: [
            { field: 'objectName', label: '姓名', colspan: 2 },
            { field: 'objectSex_txt', label: '性别', colspan: 2 },
            { field: 'objectBirthDate', label: '出生日期' }
          ]
        },
        {
          fieldParameter: [{ field: 'drugTreatmentMeasures', label: '戒毒措施', colspan: 5 }]
        },
        {
          fieldParameter: [
            { field: 'detoxificationStatus', label: '戒毒状态' },
            { field: 'inputBy', label: '录入人' },
            { field: 'inputTime', label: '录入时间' }
          ]
        },
        {
          rowspan: 2,
          rowlabel: '帮教记录',
          labelHeader: true,
          fieldParameter: [
            { field: 'recordHelpEducation', label: '帮教情况', colspan: 2 },
            { field: 'recordHelpEducationFilledBy', label: '填写人', colspan: 2 },
            { field: 'recordHelpEducationFilledTime', label: '填写时间' }
          ]
        }
      ],
      // 艾滋病危险人员-帮扶信息
      helpInfo: [
        {
          fieldParameter: [
            { field: 'accessDomainName', label: '感染途径' },
            { field: 'accessNumber', label: '是否有违法犯罪史' },
            { field: 'responseCode', label: '违法犯罪情况' }
          ]
        },
        {
          fieldParameter: [
            { field: 'accessDomainName', label: '案件类别' },
            { field: 'accessNumber', label: '关注类型' },
            { field: 'accessNumber', label: '收治情况' }
          ]
        },
        {
          fieldParameter: [{ field: 'accessDomainName', label: '收治机构名称', colspan: 5 }]
        },
        {
          fieldParameter: [
            { field: 'accessDomainName', label: '帮教类型' },
            { field: 'accessNumber', label: '帮教小组名称' },
            { field: 'accessNumber', label: '帮教小组组长' }
          ]
        },
        {
          fieldParameter: [
            { field: 'accessDomainName', label: '帮教小组组长电话', colspan: 2 },
            { field: 'accessNumber', label: '帮教时间', colspan: 2 }
          ]
        },
        {
          fieldParameter: [
            { field: 'accessDomainName', label: '帮扶人姓名', colspan: 2 },
            { field: 'accessNumber', label: '帮扶人联系方式', colspan: 2 }
          ]
        },
        {
          rowspan: 2,
          rowlabel: '帮教对象',
          labelHeader: true,
          fieldParameter: [
            { field: 'accessDomainName', label: '姓名', colspan: 2 },
            { field: 'accessDomainName', label: '性别', colspan: 2 },
            { field: 'accessDomainName', label: '出生日期' }
          ]
        }
      ],
      // 肇事肇祸等严重精神障碍患者-专项信息
      specialInfo2: [
        {
          fieldParameter: [
            { field: 'guardianIdCard', label: '监护人身份证' },
            { field: 'guardianName', label: '监护人姓名' },
            { field: 'guardianContactInformation', label: '监护人联系方式' },
            { field: 'familyEconomicStatus_txt', label: '家庭经济状况' }
          ]
        },
        {
          fieldParameter: [
            { field: 'ynSubsistenceAllowance_txt', label: '是否纳入低保' },
            { field: 'initialOnsetDate', label: '初次发病日期' },
            { field: 'currentDiagnosisType_txt', label: '目前诊断类型' },
            { field: 'accidentsNumber', label: '肇事肇祸次数' }
          ]
        },
        {
          fieldParameter: [
            { field: 'ynCausingAccidentsHistory', label: '有无肇事肇祸史' },
            { field: 'currentRiskAssessmentLevel_txt', label: '目前危险性评估等级' },
            { field: 'treatment_txt', label: '治疗情况' },
            { field: 'treatmentHospitalName', label: '治疗医院名称' }
          ]
        },
        {
          fieldParameter: [
            { field: 'reasonsHospitalization_txt', label: '实施住院治疗原因', colspan: 3 },
            { field: 'rehabilitationTrainingInstitutionName', label: '接受康复训练机构名称', colspan: 3 }
          ]
        },
        {
          fieldParameter: [
            { field: 'participatingManagementPersonnel_txt', label: '参与管理人员', colspan: 3 },
            { field: 'assistanceSituation_txt', label: '帮扶情况', colspan: 3 }
          ]
        }
      ],
      // 肇事肇祸等严重精神障碍患者-管控信息
      controlInfo: [
        {
          fieldParameter: [
            { field: 'controlPower', label: '管控力量' },
            { field: 'localPoliceStation', label: '辖区派出所' },
            { field: 'type', label: '类型' }
          ]
        },
        {
          fieldParameter: [
            { field: 'chargeControlPerson', label: '管控责任人' },
            { field: 'contactNumber', label: '联系电话' },
            { field: 'controlTime', label: '管控时间' }
          ]
        },
        {
          rowspan: 2,
          rowlabel: '管控对象',
          labelHeader: true,
          fieldParameter: [
            { field: 'controlObjectName', label: '姓名', colspan: 2 },
            { field: 'controlObjectSex_txt', label: '性别', colspan: 2 },
            { field: 'controlObjectBirthDate', label: '出生日期' }
          ]
        },
        {
          fieldParameter: [
            { field: 'inputBy', label: '录入人', colspan: 2 },
            { field: 'inputDate', label: '录入时间', colspan: 2 }
          ]
        },
        {
          rowspan: 2,
          rowlabel: '管控记录',
          labelHeader: true,
          fieldParameter: [
            { field: 'controlRecords', label: '管控记录', colspan: 2 },
            { field: 'controlRecordsBy', label: '填写人', colspan: 2 },
            { field: 'controlRecordsDate', label: '填写时间' }
          ]
        }
      ],
      // 重点青少年-人员分类及成因
      personnelClassificationInfo: [
        {
          fieldParameter: [
            { field: 'guardianIdCard', label: '监护人身份证' },
            { field: 'guardianName', label: '监护人姓名' },
            { field: 'guardianshipFee', label: '监护人关系' },
            { field: 'guardianContactInformation', label: '监护人联系方式' }
          ]
        },
        {
          fieldParameter: [
            { field: 'detailedAddress', label: '监护人居信详址' },
            { field: 'familySituation_txt', label: '家庭情况' },
            { field: 'illegalCrime_txt', label: '是否违法犯罪' },
            { field: 'personnelType_txt', label: '人员类型' }
          ]
        },
        {
          fieldParameter: [{ field: 'violationsCrimes', label: '违法犯罪情况', colspan: 7 }]
        },
        {
          fieldParameter: [
            { field: 'behaviorClassification', label: '行为分类', colspan: 3 },
            { field: 'causeAnalysis', label: '成因分析', colspan: 3 }
          ]
        }
      ],
      // 重点青少年-帮教信息
      helpTeachInfo3: [
        {
          fieldParameter: [
            { field: 'helpEducationType', label: '帮教类型' },
            { field: 'helpEducationgroupName', label: '帮教小组名称' },
            { field: 'groupLeader', label: '帮教小组组长' }
          ]
        },
        {
          fieldParameter: [
            { field: 'groupLeaderTelephone', label: '帮教小组组长电话', colspan: 2 },
            { field: 'teachingTime', label: '帮教时间', colspan: 2 }
          ]
        },
        {
          fieldParameter: [
            { field: 'helperName', label: '帮扶人姓名', colspan: 2 },
            { field: 'helperTelephone', label: '帮扶人联系方式', colspan: 2 }
          ]
        },
        {
          rowspan: 2,
          rowlabel: '帮教对象',
          labelHeader: true,
          fieldParameter: [
            { field: 'objectName', label: '姓名', colspan: 2 },
            { field: 'objectSex_txt', label: '性别', colspan: 2 },
            { field: 'objectBirthDate', label: '出生日期' }
          ]
        }
      ],
      infoData: {
        info1: {},
        info2: {}
      },
      alarmTotal: ''
    }
  },
  computed: {
    tabDatas() {
      let tabDatas = [
        { key: 1, tab: '基本信息' },
        { key: 4, type: 1, tab: '帮教信息' }, // 刑满释放人员
        { key: 5, type: 2, tab: '社区矫正人员信息' }, // 社区矫正人员
        { key: 6, type: 3, tab: '专项信息' }, // 吸毒人员
        { key: 7, type: 3, tab: '帮教记录' }, // 吸毒人员
        { key: 8, type: 4, tab: '帮扶信息' }, // 艾滋病危险人员
        { key: 9, type: 5, tab: '专项信息' }, // 肇事肇祸等严重精神障碍患者
        { key: 10, type: 5, tab: '管控信息' }, // 肇事肇祸等严重精神障碍患者
        { key: 11, type: 6, tab: '人员分类及成因' }, // 重点青少年
        { key: 12, type: 6, tab: '帮教信息' }, // 重点青少年
        { key: 2, tab: '告警信息' + this.alarmTotal },
        { key: 3, tab: '处置信息' }
      ]
      const newTabData = tabDatas.filter(item => item.type == this.type || !item.type)
      return newTabData
    },
    mtitle() {
      let mtitle = ''
      if (this.type == 1) {
        mtitle = '刑满释放人员'
      } else if (this.type == 2) {
        mtitle = '社区矫正人员'
      } else if (this.type == 3) {
        mtitle = '吸毒人员'
      } else if (this.type == 4) {
        mtitle = '艾滋病危险人员'
      } else if (this.type == 5) {
        mtitle = '肇事肇祸等严重精神障碍患者'
      } else if (this.type == 6) {
        mtitle = '重点青少年'
      }
      return mtitle
    }
  },
  beforeRouteEnter(to, from, next) {
    next(vm => {
      console.log('to', to)
      console.log('from', from)
    })
  },
  watch: {
    $route(data) {
      this.getRouteQuery(data)
    }
  },
  created() {
    this.getRouteQuery(this.$route)
  },
  methods: {
    // 获取基本信息
    getBasicInfo() {
      let api = null
      if (this.type == 1) {
        api = specialApi.getInfoRelease(this.id)
      } else if (this.type == 2) {
        api = specialApi.getInfoCorrection(this.id)
      } else if (this.type == 3) {
        api = specialApi.getInfoPoison(this.id)
      } else if (this.type == 4) {
        api = specialApi.getInfoAids(this.id)
      } else if (this.type == 5) {
        api = specialApi.getInfoSpirituality(this.id)
      } else if (this.type == 6) {
        api = specialApi.getInfoYouth(this.id)
      }
      api.then(res => {
        if (res.success) {
          let result = res.result ? res.result : {}
          this.$set(result, 'nation_txt', this.$filterDictTextByCache('nation', result.nation)) // 民族
          this.$set(result, 'maritalStatus_txt', this.$filterDictTextByCache('marital_status', result.maritalStatus)) // 婚姻状况
          this.$set(result, 'politicalOutlook_txt', this.$filterDictTextByCache('political_outlook', result.politicalOutlook)) // 政治面貌
          this.$set(result, 'education_txt', this.$filterDictTextByCache('education', result.education)) // 学历
          this.$set(result, 'religiousBelief_txt', this.$filterDictTextByCache('religious_belief', result.religiousBelief)) // 宗教信仰
          this.$set(result, 'occupationalCategory_txt', this.$filterDictTextByCache('occupation_category', result.occupationalCategory)) // 职业类别
          if (Object.keys(result).length > 0 && result.headPortrait) this.headPortrait = result.headPortrait
          this.basicInfoResult = result
        } else {
          this.$message.warn(res.message)
        }
      }).catch(e => {
        this.$message.warn('请求失败！')
      })
    },
    // 获取告警信息
    getAlarmInfo() {
      let form = Object.assign({}, { specialId: this.id }, this.pageFilter1)
      specialApi
        .getAlarm(form)
        .then(res => {
          if (res.success) {
            let result = res.result ? res.result : {}
            this.alarmInfoResult = result
            this.alarmTotal = Object.keys(result).length > 0 && result.total ? '（' + result.total + '）' : ''
          } else {
            this.$message.warn(res.message)
          }
        })
        .catch(e => {
          this.$message.warn('请求失败！')
        })
    },
    // 获取处置信息
    getDisposalInfo() {
      let form = Object.assign({}, { specialId: this.id }, this.pageFilter2)
      specialApi
        .getDisposal(form)
        .then(res => {
          if (res.success) {
            this.disposalInfoResult = res.result ? res.result : {}
          } else {
            this.$message.warn('请求失败！')
          }
        })
        .catch(e => {
          this.$message.warn('请求失败！')
        })
    },
    // 获取告警信息-切换分页
    onTableChange1(pagination, pageFilter, sorter) {
      this.pageFilter1 = Object.assign({}, this.pageFilter1, pagination)
      this.getAlarmInfo()
    },
    // 获取处置信息-切换分页
    onTableChange2(pagination, pageFilter, sorter) {
      this.pageFilter2 = Object.assign({}, this.pageFilter2, pagination)
      this.getDisposalInfo()
    },
    // 获取帮教信息、社区矫正人员信息、专项信息、帮教记录、帮扶信息、管控信息、人员分类及成因
    getItemApi() {
      let api1, api2
      if (this.type == 1) {
        api1 = specialApi.getEducationInfoRelease(this.id)
      } else if (this.type == 2) {
        api1 = specialApi.getCommunityCorrectionInfo(this.id)
      } else if (this.type == 3) {
        api1 = specialApi.getSpecialInformationPoison(this.id)
        api2 = specialApi.getRecordsPoison(this.id)
      } else if (this.type == 4) {
        api1 = specialApi.getInfoAids(this.id)
      } else if (this.type == 5) {
        api1 = specialApi.getSpecialInformationSpirituality(this.id)
        api2 = specialApi.getControlSpirituality(this.id)
      } else if (this.type == 6) {
        api1 = specialApi.getYouthCauses(this.id)
        api2 = specialApi.getInfoYouthId(this.id)
      }
      api1.then(res => {
        if (res.success) {
          let result = res.result ? res.result : {}
          // 刑满释放人员--帮教信息
          this.$set(result, 'ynRecidivism_txt', this.$filterDictTextByCache('yn', result.ynRecidivism)) // 是否累犯
          this.$set(result, 'originalSinName_txt', this.$filterDictTextByCache('place_of_detention', result.originalSinName)) // 原罪名
          this.$set(result, 'typeOfHazardAssessment_txt', this.$filterDictTextByCache('dangerous', result.typeOfHazardAssessment)) // 危险性评估类型
          this.$set(result, 'connection_txt', this.$filterDictTextByCache('connection', result.connection)) // 衔接情况
          this.$set(result, 'placement_txt', this.$filterDictTextByCache('resettlement', result.placement)) // 安置情况
          this.$set(result, 'recidivism_txt', this.$filterDictTextByCache('yn', result.recidivism)) // 是否重新犯罪
          // 社区矫正人员--社区矫正人员信息
          this.$set(result, 'tiredRecidivist_txt', this.$filterDictTextByCache('yn', result.tiredRecidivist)) // 是否累惯犯
          this.$set(result, 'fourHistories_txt', this.$filterDictTextByCache('four_histories', result.fourHistories)) // "四史"情况
          this.$set(result, 'threeInvolved_txt', this.$filterDictTextByCache('three_references', result.threeInvolved)) // "三涉"情况
          this.$set(result, 'correctionCategory_txt', this.$filterDictTextByCache('correction_category', result.correctionCategory)) // 矫正类别
          this.$set(result, 'ynCorrectionTeam_txt', this.$filterDictTextByCache('yn', result.ynCorrectionTeam)) // 是否建立矫正小组
          this.$set(result, 'correctionTeamPersonnel_txt', this.$filterDictTextByCache('correction_type', result.correctionTeamPersonnel)) // 矫正小组人员
          this.$set(result, 'correctionReleaseType_txt', this.$filterDictTextByCache('correction_release', result.correctionReleaseType)) // 矫正解除(终止)类型
          this.$set(result, 'ynGetRidControl_txt', this.$filterDictTextByCache('yn', result.ynGetRidControl)) // 是否有脱管
          this.$set(result, 'ynLeakAdminister_txt', this.$filterDictTextByCache('yn', result.ynLeakAdminister)) // 是否有漏管
          this.$set(result, 'accompliceSex_txt', this.$filterDictTextByCache('sex', result.accompliceSex)) // 同案犯-性别
          // 吸毒人员--专项信息
          this.$set(result, 'control_txt', this.$filterDictTextByCache('control', result.control)) // 管控情况
          // 肇事肇祸等严重精神障碍患者-专项信息
          this.$set(result, 'familyEconomicStatus_txt', this.$filterDictTextByCache('family_economic_status', result.familyEconomicStatus)) // 家庭经济状况
          this.$set(result, 'ynSubsistenceAllowance_txt', this.$filterDictTextByCache('yn', result.ynSubsistenceAllowance)) // 是否纳入低保
          this.$set(result, 'currentDiagnosisType_txt', this.$filterDictTextByCache('current_diagnostic_type', result.currentDiagnosisType)) // 目前诊断类型
          this.$set(result, 'currentRiskAssessmentLevel_txt', this.$filterDictTextByCache('current_hazard_assessment_level', result.currentRiskAssessmentLevel)) // 目前危险性评估等级
          this.$set(result, 'treatment_txt', this.$filterDictTextByCache('treatment', result.treatment)) // 治疗情况
          this.$set(result, 'reasonsHospitalization_txt', this.$filterDictTextByCache('reason', result.reasonsHospitalization)) // 实施住院治疗原因
          this.$set(result, 'participatingManagementPersonnel_txt', this.$filterDictTextByCache('management', result.participatingManagementPersonnel)) // 参与管理人员
          this.$set(result, 'assistanceSituation_txt', this.$filterDictTextByCache('assistance', result.assistanceSituation)) // 帮扶情况
          // 重点青少年-人员分类及成因
          this.$set(result, 'familySituation_txt', this.$filterDictTextByCache('family_situation', result.familySituation)) // 家庭情况
          this.$set(result, 'illegalCrime_txt', this.$filterDictTextByCache('yn', result.illegalCrime)) // 是否违法犯罪
          this.$set(result, 'personnelType_txt', this.$filterDictTextByCache('personnel_type', result.personnelType)) // 人员类型
          // 重点青少年-帮教信息
          this.$set(result, 'objectSex_txt', this.$filterDictTextByCache('sex', result.objectSex)) // 帮教对象-性别
          this.$set(this.infoData, 'info1', result)
        } else {
          this.$message.warn(res.message)
        }
      }).catch(e => {
        this.$message.warn('请求失败！')
      })
      if (!api2) return
      api2.then(res => {
        if (res.success) {
          let result = res.result ? res.result : {}
          // 吸毒人员--帮教记录
          this.$set(result, 'objectSex_txt', this.$filterDictTextByCache('sex', result.objectSex)) // 帮教对象-性别
          // 肇事肇祸等严重精神障碍患者-管控信息
          this.$set(result, 'controlObjectSex_txt', this.$filterDictTextByCache('sex', result.controlObjectSex)) // 管控对象-性别
          this.$set(this.infoData, 'info2', result)
        } else {
          this.$message.warn(res.message)
        }
      }).catch(e => {
        this.$message.warn('请求失败！')
      })
    },
    // 处置
    handleDispose(status, record) {
      this.$refs.disposeModal.show(status, record)
    },
    handleDeleteDispose(record) {
      let that = this
      this.$confirm({
        title: `确定删除该条处置信息？`,
        okText: '确定',
        onOk() {
          specialApi
            .deleteDisposal(record.disposeId)
            .then(async res => {
              if (res.success) {
                that.$message.success(res.message)
                that.getDisposalInfo()
              } else {
                that.$message.warn(res.message)
              }
            })
            .catch(e => {
              that.$message.warn('请求失败！')
            })
        }
      })
    },
    showDispose() {
      this.visible = false
      this.handleDispose('alarmDispose', this.alarmInfo)
    },
    showModal(record) {
      this.alarmInfo = record
      this.visible = true
    },
    hideModal() {
      this.visible = false
    },
    // 一键报警
    handleAlarm(record) {
      this.$refs.alarmModal.show()
    },
    changeImage(val) {
      if (!this.headPortrait) return
      specialApi.changeAvatar({ avatarUrl: this.headPortrait, specialPersonnelId: this.id }).then(res => {
        if (res.success) {
          this.$message.success(res.message)
        } else {
          this.$message.warn(res.message)
        }
      })
      .catch(e => {
        this.$message.warn('请求失败！')
      })
    },
    getOk(status) {
      if (status == 'addDispose' || status == 'editDispose') {
        this.getDisposalInfo()
      } else if (status == 'alarmDispose') {
        this.getAlarmInfo()
      }
    },
    // 监听路由变化
    getRouteQuery($route) {
      if ($route.query && Object.keys($route.query).length > 0) {
        let query = $route.query
        if (query.type) {
          this.type = query.type
        }
        if (query.id) {
          this.id = query.id
          this.getBasicInfo()
          this.getAlarmInfo()
          this.getDisposalInfo()
          this.getItemApi()
        }
      }
      // if ($route.meta && Object.keys($route.meta).length > 0) {
      //   let meta = $route.meta
      //   if (meta.title) {
      //     meta.title = this.mtitle + '详情'
      //   } else {
      //     this.$set(meta, 'title', this.mtitle + '详情')
      //   }
      // }
    }
  }
}
</script>
<style lang="less" scoped>
/deep/.ant-descriptions-item-label {
  width: 200px;
}
/deep/.ant-upload-list-picture-card .ant-upload-list-item {
  width: 160px;
  height: 160px;
  border-width: 0;
  padding: 0;
}
/deep/.ant-upload.ant-upload-select-picture-card {
  width: 160px;
  height: 160px;
}
/deep/.iconp .anticon {
  font-size: 28px;
}
/deep/ .ant-upload-text {
  margin-top: 6px;
}
</style>
